package leetcode.offer;

import java.util.HashSet;
import java.util.Set;

/**
 * @ClassName T01
 * @Description TODO
 * @Author Fanxc
 * @DATE 2020/11/29 0029 19:46
 * @Version 1.0
 */
public class T03 {
    class Solution {
        /**
         * @return int
         * @Author Fanxc
         * @Description //TODO
         * @Date 2020/11/29 0029 19:51
         * @Param [nums]
         **/

        public int findRepeatNumber(int[] nums) {
            Set<Integer> set = new HashSet<>();
            for (int num : nums) {
                if (set.contains(num)) {
                    return num;
                } else {
                    set.add(num);
                }
            }
            return 0;
        }
    }
}
